<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- <使用过滤器> -->、
        <h1>{{phone | formatPhone}}</h1>
        <h1>{{time | formatTime}}</h1>
    </div>
</body>

</html>
<script src="./vue-2.5.21.js"></script>
<script>
    // 定义全局过滤器
    Vue.filter('formatPhone', (p)=> {
        return p.slice(0, 3) + "****" + p.slice(-4);
    })
    Vue.filter('formatTime', (t)=> {
        return `${t.getFullYear()}-${t.getMonth()}-${t.getDate
            ()}`;
    })
    var v = new Vue({
        el: '#app',
        data: {
            phone: '13611129070',
            time: new Date()
        },
        filters: {

        }
    })
</script>